<?php
  $appid = $_POST['appid'];
  $appkey = $_POST['appkey'];
  $te_id = $_POST['te_id'];
  $te_ids = $_POST['te_ids'];
  $sign = $_POST['sign'];
  $admin_phone = $_POST['admin_phone'];

  include_once("../../untils/conn.php");
  if ($con) {
    mysqli_query($con, "set names utf8");
    $result = mysqli_query($con, "SELECT * FROM sms WHERE id=1");
    if (mysqli_num_rows($result) > 0) {
      $data = mysqli_query($con, "UPDATE sms SET appid='$appid', appkey='$appkey', te_id='$te_id', te_ids='$te_ids', sign='$sign', admin_phone='$admin_phone' WHERE id=1");
      if ($data > 0) {
        echo "<script>alert('修改信息成功');window.location.href='../Smsytem.php'</script> ";
      } else {
        echo ("<script>alert('修改失败');window.location.replace(document.referrer)</script>");
      }
    } else {
      $data = mysqli_query($con, "INSERT INTO sms (appid, appkey, te_id, te_ids, sign, admin_phone) VALUES ('$appid', '$appkey', '$te_id', '$te_ids', '$sign', '$admin_phone')");
      if ($data > 0) {
        echo "<script>alert('添加信息成功');window.location.href='../Smsytem.php'</script> ";
      } else {
        echo ("<script>alert('添加失败');window.location.replace(document.referrer)</script>");
      }
    }
  }
  $con->close();
?>
